from django.urls import re_path
from django.contrib.auth.decorators import login_required
from apps.user.views import RegisterView, ActiveView, LoginView, LogoutView, UserInfoView, UserOrderView, AddressView
app_name = 'user'


urlpatterns = [
    # re_path(r'^register$', views.register, name='register'),
    # re_path(r'^register_handle$', views.register_handle, name='register_handle')
    re_path(r'^register$', RegisterView.as_view(), name='register'),
    re_path(r'^active/(?P<token>.*)$', ActiveView.as_view(), name='active'),
    re_path(r'^login$', LoginView.as_view(), name='login'),
    re_path(r'^logout$', LogoutView.as_view(), name='logout'), # 注销登录

    # 方法一，使用函数检查登录装饰器 login_required(UserInfoView.as_view()),
    # re_path(r'^$', login_required(UserInfoView.as_view()), name='user'),  # 用户中心-信息页
    # re_path(r'^order$', login_required(UserOrderView.as_view()), name='order'), # 用户中心-订单页
    # re_path(r'^address$', login_required(AddressView.as_view()), name='address'), # 用户中心-地址页
    # 方法二，继承LoginRequiredMixin对象，进行检查。
    re_path(r'^$', UserInfoView.as_view(), name='user'),  # 用户中心-信息页
    re_path(r'^order$', UserOrderView.as_view(), name='order'), # 用户中心-订单页
    re_path(r'^address$', AddressView.as_view(), name='address'), # 用户中心-地址页
]
